package cm.day12;


class MyThead extends Thread {
    static int sum = 0;

    @Override
    public void run() {
        while (true) {

            if (sum < 100) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                sum++;
                System.out.println(getName() + sum + "张票");
            }else {
                break;
            }
        }

    }
}


public class Test1 {
    public static void main(String[] args) {
        MyThead my1 = new MyThead();
        MyThead my2 = new MyThead();
        MyThead my3 = new MyThead();
        my1.setName("A");
        my2.setName("B");
        my3.setName("C");
        my1.start();
        my2.start();
        my3.start();
    }
}
